import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 食物分类信息 */
export interface RecipeFoodType {
  id: number // 编号
  sid: string // 分类id
  name?: string // 分类名称
  sort?: number // 排序
  status?: number // 状态
}

// 食物分类 API
export const RecipeFoodTypeApi = {
  // 查询食物分类分页
  getRecipeFoodTypePage: async (params: any) => {
    return await request.get({ url: `/school/recipe-food-type/page`, params })
  },

  // 查询食物分类精简版列表
  getSimpleRecipeFoodType: async () => {
    return await request.get({ url: `/school/recipe-food-type/simple-list` })
  },

  // 查询食物分类详情
  getRecipeFoodType: async (id: number) => {
    return await request.get({ url: `/school/recipe-food-type/get?id=` + id })
  },

  // 新增食物分类
  createRecipeFoodType: async (data: RecipeFoodType) => {
    return await request.post({ url: `/school/recipe-food-type/create`, data })
  },

  // 修改食物分类
  updateRecipeFoodType: async (data: RecipeFoodType) => {
    return await request.put({ url: `/school/recipe-food-type/update`, data })
  },

  // 删除食物分类
  deleteRecipeFoodType: async (id: number) => {
    return await request.delete({ url: `/school/recipe-food-type/delete?id=` + id })
  },

  /** 批量删除食物分类 */
  deleteRecipeFoodTypeList: async (ids: number[]) => {
    return await request.delete({
      url: `/school/recipe-food-type/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出食物分类 Excel
  exportRecipeFoodType: async (params) => {
    return await request.download({ url: `/school/recipe-food-type/export-excel`, params })
  }
}
